package com.example.xunwuproject.repository;

import com.example.xunwuproject.entity.HouseSubscribe;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2019-03-16
 **/
public interface HouseSubscribeRepository extends JpaRepository<HouseSubscribe, Long> {


    HouseSubscribe findByHouseIdAndUserId(Long id, Long loginUserId);

    Page<HouseSubscribe> findAllByUserIdAndStatus(Long userId, int value, Pageable pageable);


    Page<HouseSubscribe> findAllByAdminIdAndStatus(Long adminId, int status, Pageable pageable);

    HouseSubscribe findByHouseIdAndAdminId(Long houseId, Long adminId);


    @Modifying
    @Query("update HouseSubscribe as subscribe set subscribe.status = :status where subscribe.id = :id")
    void updateStatus(@Param(value = "id") Long id, @Param(value = "status")int status);
}


